﻿<%@ WebHandler Language="C#" Class="lists" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;

public class lists : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        //string query = HttpContext.Current.Request.Params["wallet_type"];

        //if (string.IsNullOrEmpty(query))
        //{
        //    HttpContext.Current.Response.Write("parameter error");
        //    return;
        //}

        //{"code":1,"msg":"获取成功","time":"1608190962","data":{"total":3,"per_page":10,"current_page":1,"last_page":1,"data":[{"id":3,"title":"测试模式~~~~~~~~","content":"测试模式~~~~~~~~","createtime":1604424616,"updatetime":1604424616},{"id":2,"title":"商品退货了，谁承担运费？","content":"亲，平台运费规则秉承“谁过错，谁承担”的原则,如非商家或者物流问题，建议您联系商家协商处理，售后，退货运费需要您自行承担;如商品存在质量问题、商家发错货等情况，退货运费由商家承担。为了更好的保障您的权益，请您保留好相关凭证,退货物流费用麻烦您先垫付，不要使用到付，待商家收到您寄回的商品，退款成功后，您可以凭借凭证联系商家处理~","createtime":1582259745,"updatetime":1586946960},{"id":1,"title":"付款后订单显示待付款？","content":"如您账户显示已扣款，但订单交易状态显示”等待付款”，可能是由于网络繁忙导致数据延迟，建议您稍后关注订单交易状态以及交易账户流水情况。","createtime":1582259738,"updatetime":1590746459}]}}

        var code = 1;
        var msg = "获取成功";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {

            var Bpl = bll.User.Select(x => new
            {
                id=x.UID,
                title=x.UNickName,
                type_name=x.Utype,
                createtime=x.RegTime,
                img=x.UHeadImg
            });//全部.ToList();



            var total =Bpl.Count();
            var per_page = 10;
            var current_page=1;
            var last_page=1;

            var data = new { total,per_page,current_page, last_page,data=Bpl};
            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data}));

        }

        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }

    public bool IsReusable {
        get {
            return false;
        }
    }




}